home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctjoc85.arc / TRIG.F77 < prev    next >
Text File  |  1985-03-16  |  1KB  |  50 lines

  1. *     trig test
  2. *                  2        2
  3. *     calculate sin  x + cos  x for -90 <= x <= 90
  4. *
  5. *     the maximum error is saved and printed after 'iters'
  6. *     calculations in real*4 and real*8
  7.  
  8.       program     trig test
  9.  
  10.       real*4      x,   sx,   cx,   error,   radians
  11.       real*8      d x, d sx, d cx, d error, d radians
  12.       integer*2   iters
  13.       integer*2   max iters
  14.       integer*2   i
  15.       integer*2   t1 (4), t2 (4)
  16.  
  17.       radians (i)   = float (i)*0.01745 32925
  18.       d radians (i) = float (i)*0.01745 32925 19943 D 0
  19.  
  20.       write (*, *)' iters: '
  21.       read  (*, *) max iters
  22.       call time (t1)
  23.       do 200 iters = 1, max iters
  24.          error = 0.0
  25.          do 100 i = -90, 90
  26.             x   = radians (i)
  27.             sx  = sin (x)
  28.             cx  = cos (x)
  29.             error = max (error, abs (1.0 - sx**2 - cx**2))
  30. 100         continue
  31. 200      continue
  32.       call etime (t2, t1, max iters)
  33.       write (*, *)'real*4 error', error
  34.       write (*, *)' '
  35.  
  36.       call time (t1)
  37.       do 400 iters = 1, max iters
  38.          d error = 0.0
  39.          do 300 i = -90, 90
  40.             d x  = d radians (i)
  41.             d sx = sin (d x)
  42.             d cx = cos (d x)
  43.             d error = max (d error, abs (1.0 - d sx**2 - d cx**2))
  44. 300         continue
  45. 400      continue
  46.  
  47.       call etime (t2, t1, max iters)
  48.       write (*, *) 'real*8 error', d error
  49.       end
  50.